<template>
	<count-to
		:start-val="Number(start)"
		:end-val="Number(endVal)"
		:duration="Number(duration)"
		:decimals="Number(decimals)"
		:suffix="suffix"
	></count-to>
</template>
<script lang="ts" setup>
	import { defineProps, ref, watch } from 'vue';
	import CountTo from '../CountTo/index.vue';
	const props = defineProps({
		startVal: {
			type: [String, Number],
			default: 0,
		},
		endVal: {
			type: [String, Number],
			default: 0,
		},
		duration: {
			type: [String, Number],
			default: 1000,
		},
		decimals: {
			type: [String, Number],
			default: 2,
		},
		suffix: {
			type: String,
			default: '',
		},
	});
	let start = ref(props.startVal);
	watch(
		() => props.endVal,
		(newVal, oldVal) => {
			start.value = oldVal;
		}
	);
</script>
